package com.parkingspace.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.parkingspace.entity.Appraise;
import com.parkingspace.service.impl.AppraiseServiceImpl;
import com.parkingspace.service.impl.UserServiceImpl;
import com.parkingspace.util.Constants;
import com.parkingspace.util.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

/**
 * <p>
 * 评价表 前端控制器
 * </p>
 *
 * @author Gapper
 * @since 2021-06-01
 */
@RestController
@RequestMapping("/appraise")
public class AppraiseController {

    @Autowired
    private AppraiseServiceImpl appraiseService;

    @Autowired
    private UserServiceImpl userService;




    @PostMapping("/getAppraiseList")
    public ResultVO getComplainList(String token,Appraise appraise,Page page) {
        System.out.println("getComplainList进来了+++++++（全查）"+appraise);
        System.out.println("每页大小："+page.getSize());
        System.out.println("当前页："+page.getCurrent());
        System.out.println("总页数："+page.getTotal());
        System.out.println("总记录数："+page.getRecords());
        System.out.println("getPages:"+page.getPages());
        System.out.println("getRecords:"+page.getRecords());

        ResultVO resultVO;


        System.out.println("1111111111111");
        IPage pages = appraiseService.getAppraiseList(appraise, page);
        System.out.println("2222222222222");
        System.out.println(pages.getRecords());
        System.out.println("3333333333333");

        if (token==null){
            return null;
        }

        if (pages==null){
            return new ResultVO(Constants.OPER_FAILURE,"查询失败1",pages);
        }
        return new ResultVO(Constants.OPER_SUCCESS,"成功",pages);
    }




    @DeleteMapping("/delAppraiseById")
    public ResultVO delAppraiseById(Appraise appraise) {
        System.out.println("进来了+++++++（删除）"+appraise.getAppraiseId());
        ResultVO resultVO;
        List<Appraise> appraiseList=null;
        boolean f=appraiseService.delAppraiseById(appraise.getAppraiseId());


        if (f!=true){
            System.out.println("6666666");
            return new ResultVO(Constants.OPER_FAILURE,"删除失败",false);
        }
        System.out.println("555555");
        return new ResultVO(Constants.OPER_SUCCESS,"删除成功",true);



    }

}

